﻿/*****************************************介绍*****************************************
 * 作者：24531
 * 创建时间：2025-08-17 21:41:56
 * 功能：内购配置
**************************************************************************************/

using System.Collections.Generic;
using UnityEngine.Purchasing;

namespace Game.BaseData
{
    public partial class Config
    {
        public class IAP
        {
            public int cent;
            public string currency;
            public string currencyUnit;
            public string th_u;
            public int freeCoinInterval;        // 免费金币领取间隔时间
            public int freeDiamondInterval;     // 免费钻石领取间隔时间
            public Product[] products;
            private Dictionary<string, Product> m_ProductDict;

            public void Parse()
            {
                if (products != null)
                {
                    m_ProductDict = new Dictionary<string, Product>(products.Length);
                    for (int i = 0; i < products.Length; i++)
                        m_ProductDict[products[i].id] = products[i];
                }
            }

            public Product this[string productId]
            {
                get
                {
                    m_ProductDict.TryGetValue(productId, out Product result);
                    return result;
                }
            }

            public class Product
            {
                public string id;
                public string th;
                public ProductType type;
                public bool bestCh;
                public float amount;
                public Reward reward;
            }

            public class Reward
            {
                public E_AwardType type;
                public int[] amount;
            }

            public enum E_AwardType
            {
                None = -1,
                Coin,                       // 金币
                Star,                       // 星星
            }
        }
    }
}